#ifndef INFOBOX_H
#define INFOBOX_H

#include <QObject>
#include <QGraphicsWidget>
#include <QGraphicsLinearLayout>
#include <QPainter>
#include <QLabel>
#include <QGraphicsProxyWidget>
#include <QTableWidget>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QLineEdit>
#include <QColorDialog>
#include <QPushButton>
#include <QComboBox>

#include "../../VisBaseClasses/visbaseelement.h"


class MultiGeneRegionVisWidget;
class GenomeElementDataPacket;
class GenomeElement;


//---------------------------------------------------------------------------
class InfoTab : public QWidget
{
    Q_OBJECT

public:
    InfoTab(GenomeElementDataPacket* dataToDisplay, QWidget *parent = 0);
    //~InfoTab();

private:
    QVBoxLayout* mainLayout;
    GenomeElementDataPacket* dataToDisplay;

    QTextEdit* infoText;
};

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

class ColorTab : public QWidget
{
    Q_OBJECT

public:
    ColorTab(GenomeElement* elt, QColor currentColor, QString currentColorAppliedTo, QWidget *parent = 0);
    //~ColorTab();

public slots:
    void getNewColor();

private:
    GenomeElement* elt;

    QColorDialog* colorDialog;

    QVBoxLayout* mainLayout;

    QHBoxLayout* colorHorizontalLayout;
    QLabel* colorLabel;
    QPixmap* colorPixmap;
    QLabel* colorPixmapLabel;
    QPushButton* selectNewColorButton;
    //QComboBox* colorModeComboBox;
};

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

class PositionTab : public QWidget
{
    Q_OBJECT
public:
    PositionTab(GenomeElement* elt, QWidget *parent = 0);

signals:
    void targetSignal(QColor leftColor, QColor rightColor, QColor startColor);

public slots:
    void emitTargetSignal();

private:
    QVBoxLayout* positionHorizontalLayout;
//    QHBoxLayout* centerLayout;
//    QHBoxLayout* bringToTopLayout;

//    QLabel* centerThisLabel;
//    QComboBox* centerComboBox;
//    QPushButton* centerGoButton;

    QPushButton* centerButton;
    QPushButton* bringToTopButton;
    QPushButton* alignButton;
    QPushButton* allButton;

    static int targetCount;



};


////---------------------------------------------------------------------------
////---------------------------------------------------------------------------

//class PositionTab : public QWidget
//{
//    Q_OBJECT
//public:
//    PositionTab(GenomeElement* elt, QWidget *parent = 0);

//private:
//    QVBoxLayout* positionHorizontalLayout;
////    QHBoxLayout* centerLayout;
////    QHBoxLayout* bringToTopLayout;

////    QLabel* centerThisLabel;
////    QComboBox* centerComboBox;
////    QPushButton* centerGoButton;

//    QPushButton* centerButton;
//    QPushButton* bringToTopButton;
//    QPushButton* alignButton;
//    QPushButton* allButton;





//};




class InfoBox : public VisBaseElement
{
    Q_OBJECT
public:
    explicit InfoBox( GenomeElement* elt, GenomeElementDataPacket* data, int dir, QPointer<SageVis> sageVisPointer, VisBaseWidget* parentWidget, QGraphicsItem *parent = 0);
    //~InfoBox();

    typedef VisBaseElement super;

    //these allow elts to be drawn
    QRectF boundingRect() const;
    QPainterPath shape() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
               QWidget *widget);

    void setGeometry(const QRectF &geom);
    void setGeometry( qreal x, qreal y, qreal w, qreal h );

//    void setWidth(float newWidth);
//    void setHeight(float newHeight);

    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
    //void hoverMoveEvent(QGraphicsSceneHoverEvent *event);

    void setDirection(int dir);

signals:
    
public slots:

protected:

    GenomeElementDataPacket* data;
    GenomeElement* elt;

    int direction;

    QPoint trianglePt1;
    QPoint trianglePt2;
    QPoint trianglePt3;

    QRectF mainRect;
    //QGraphicsRectItem* mainRect;

    QGraphicsLinearLayout* mainLayout;
    
    QFont* font;
    //QLabel* title;
    QLineEdit* title;
    QGraphicsProxyWidget* titleProxy;

    QTabWidget* tabWidget;
    QGraphicsProxyWidget* tabWidgetProxy;

    InfoTab* infoTab;
    ColorTab* colorTab;
    PositionTab* positionTab;

    float width;
    float height;

    void init();
    void setupShape();

    QColor oldColor;
};

#endif // INFOBOX_H
